<?xml version="1.0" encoding="ISO-8859-1" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:c="http://java.sun.com/jsp/jstl/core" version="2.0">
	<jsp:directive.page contentType="text/html; charset=ISO-8859-1"
		pageEncoding="ISO-8859-1" session="false" />
	<jsp:output doctype-root-element="html"
		doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
		doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
		omit-xml-declaration="true" />
	<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test Page.</title>
</head>
<body>
${pageContext.request.serverName}
	Hello <c:out value="world."/>  from address: <c:out value="${pageContext.request.remoteHost}"/>
	<jsp:scriptlet>
	//com.gmatous.Calculator calc = new com.gmatous.Calculator();
		   //	calc.check();
			/*
			java.util.logging.Logger utillog = java.util.logging.Logger.getLogger("txdot");
			org.apache.log4j.Logger log4jlog = org.apache.log4j.Logger.getLogger("txdot");

			System.out.println("GMATOUS check. System.out");
			System.err.println("GMATOUS check. System.err");
			utillog.log(java.util.logging.Level.WARNING, "GMATOUS check. utillog");
			log4jlog.warn("GMATOUS check. log4jlog");
		
	*/
			String DATASOURCE_CONTEXT = "java:comp/env/jdbc/Postgres";
			String dbname = "unknown";

			java.util.logging.Logger log = java.util.logging.Logger.getLogger("main");
			java.sql.Connection result = null;
			try {
				javax.naming.Context initialContext = new javax.naming.InitialContext();
				if (initialContext == null) {

					log.warning("JNDI problem. Cannot get InitialContext.");
				}
				javax.sql.DataSource datasource = (javax.sql.DataSource) initialContext.lookup(DATASOURCE_CONTEXT);
				if (datasource != null) {
					result = datasource.getConnection();
				    dbname = result.getMetaData().getDatabaseProductName();
					System.out.println(dbname);
					out.print(dbname);
				}
				else {
					log.warning("Failed to lookup datasource.");
				}
			} catch (javax.naming.NamingException ex) {
				log.warning("Cannot get connection: " + ex);
			} catch (java.sql.SQLException ex) {
				log.warning("Cannot get connection: " + ex);
			}
			</jsp:scriptlet>
			<br/>
			<jsp:expression>"Database name: " +  dbname.toString() </jsp:expression>

</body>
	</html>
</jsp:root>

